/**
* @file rtcommon.h in loosely_couple_h7
* @author rebeater
* @comment tool funcitons for real time application
* Create on 3/24/21 3:38 PM
* @version 1.0
**/

//
// Created by rebeater on 3/24/21.
//

#ifndef LOOSELY_COUPLE_H7_RTCOMMON_H
#define LOOSELY_COUPLE_H7_RTCOMMON_H
#include "defines.h"
#include <stdio.h>
#include <math.h>
//char buffer[8];
#include "NavStruct.h"
#if USE_STIM300== 1
#include <stim300.h>
#define IMU_RAW ImuRawStim
#define RAW_TO_IMU(X,Y) stim300_convert_to_imu(X,Y)
#else
#include <adis16460.h>
#define IMU_RAW ImuRawAdi
#define RAW_TO_IMU(X,Y) convert_adi_to_double(X,Y)
#endif
#include "rtcommon.h"
#include <led.h>
#include <agilex.h>
#define info(s,...) trace(Info,(s));
extern DateTime date_time;
double systemTimeToGpst(uint32_t timer_cnt, uint32_t cnt, uint32_t pps_margin);

void printDouble(double d, uint8_t n);

void sprintDouble(char *buffer, double d, uint8_t n);

void printOutput(NavOutput *out);

void sprintOutput(char *buffer, NavOutput *out);

uint32_t crc_checksum(const uint8_t *indata, int num_bytes);

void gpst_to_utc(int week, double gpst,DateTime *time);
int day_from_gps0(const int year, const int mon, const int day);
typedef enum {
    Info,
    Warning,
    Error,
    Fetal,
} TraceLevel;

int trace(TraceLevel level, char *fmt, ...);

#endif //LOOSELY_COUPLE_H7_RTCOMMON_H
